
/* 选择内设部门带人数树--列表左侧 */
function queryConnectTreeLeft() {
    if ($(this).width() < 1000) {
        leftTreeIndent();
    }else {
        $(".fw-tree-left").next().removeClass("fw-right-container-extension");
        $(".fw-tree-left").next().addClass("fw-right-container-shrink");
    }
    // 操作栏-展开/折叠
    $('#tree-foldbar-outdent').on('click', function () {
        leftTreeOutdent();
    });
    $('#tree-foldbar-indent').on('click', function () {
        leftTreeIndent();
    });

    var url = ctx + "osfw/dbadminer/connect/databaseTreeImmediateChild";
    var options = {
        id: 'connect-tree-left',
        url: url,
        expandLevel: 1,
        onClick: zOnDeptClick
    };
    $.tree.init(options);

    // 点击树节点回调
    function zOnDeptClick(event, treeId, treeNode) {
        $("#deptId").val(treeNode.id);
        $.table.search();
    }

    // 操作栏-展开/折叠
    function leftTreeOutdent() {
        $(".fw-tree-left").next().removeClass("fw-right-container-extension");
        $(".fw-tree-left").next().addClass("fw-right-container-shrink");
        $(".fw-tree-left").removeClass("fw-tree-left-indent");
        $(".fw-tree-left").addClass("fw-tree-left-outdent");
        $(".fw-tree-left .tree-header, .fw-tree-left .tree-wrapper").removeClass("am-hide");
        $("#tree-foldbar-outdent").addClass("am-hide");
        $('#tree-foldbar-indent').removeClass("am-hide");
    }
    function leftTreeIndent() {
        $(".fw-tree-left").next().removeClass("fw-right-container-shrink");
        $(".fw-tree-left").next().addClass("fw-right-container-extension");
        $(".fw-tree-left .tree-header, .fw-tree-left .tree-wrapper").addClass("am-hide");
        $(".fw-tree-left").removeClass("fw-tree-left-outdent");
        $(".fw-tree-left").addClass("fw-tree-left-indent");
        $("#tree-foldbar-indent").addClass("am-hide");
        $('#tree-foldbar-outdent').removeClass("am-hide");
    }

    // 按钮事件
    $('#btnExpand').click(function () {
        $._tree.expandAll(true);
        $(this).hide();
        $('#btnCollapse').show();
    });
    $('#btnCollapse').click(function () {
        $._tree.expandAll(false);
        $(this).hide();
        $('#btnExpand').show();
    });
    $('#btnRefresh').click(function () {
        queryConnectTreeLeft();
        $.form.reset();
        $.table.search();
    });
}